using System.Collections.Generic;
using UnityEngine;

namespace LS.SimpleInput
{
    public class GestureState
    {
        public GestureType GestureType = GestureType.None;
        public InputPhase Phase = InputPhase.None;
        public float StartTime = 0;
        public float DeltaTime = 0;
        public float LastTime = 0;
        public float Duration = 0;

        public bool EventSystemDetected;

        public Vector2 StartPoint;
        public Vector2 Point;
        public Vector2 DeltaPoint;

        public bool Active
        {
            get
            {
                return Phase != InputPhase.None;
            }
        }

        public virtual bool Effective
        {
            get
            {
                return Phase != InputPhase.None && Phase != InputPhase.Canceled;
            }
        }

        public bool BeganThisFrame
        {
            get
            {
                return Phase == InputPhase.Began;
            }
        }

        public bool CancledThisFrame
        {
            get
            {
                return Phase == InputPhase.Canceled;
            }
        }

        public bool EndThisFrame
        {
            get
            {
                return Phase == InputPhase.Ended;
            }
        }
        public bool Moving
        {
            get
            {
                return Phase == InputPhase.Moved;
            }
        }

        public bool Stationary
        {
            get
            {
                return Phase == InputPhase.Stationary;
            }
        }
    }

    public class TriggerGestureState: GestureState
    {
        public bool TriggerThisFrame = false;
        public override bool Effective
        {
            get
            {
                return Phase != InputPhase.None && Phase != InputPhase.Canceled && Phase != InputPhase.Moved;
            }
        }
    }

    public class TimerGestureState : GestureState
    {
        public float MinimumDuration;
        public float TimerBeginingTime = 0;
        public bool TimerBegining = false;
        public bool TimerBeginingThisFrame = false;
    }

    public class DoubleTriggerGestureState : TriggerGestureState
    {
        public bool InDoubleTrigger;
        public float LastTriggerTime;
        public float MinimumDoubleTriggerDuration;
    }

    public class MovementGestureState : GestureState
    {
        public MoveDirection MoveDirection;
    }
}
